//
//  ShellWallertViewController.m
//  ShellWallert
//
//  Created by lvzhao on 2019/5/13.
//  Copyright © 2019 吕VV. All rights reserved.
//

#import "ShellWallertViewController.h"
#import "ShellWallertView.h"
#import "ShellWallertViewModel.h"

@interface ShellWallertViewController ()

@property (nonatomic,strong) ShellWallertView *wallertView;

@property (nonatomic,strong) ShellWallertViewModel *viewModel;

@end

@implementation ShellWallertViewController


- (instancetype)init
{
    self = [super init];
    if (self) {
        
        @weakify(self);
        [[[NSNotificationCenter defaultCenter] rac_addObserverForName:k_APPLanguageWillChangeNotificationName object:nil] subscribeNext:^(NSNotification * _Nullable x) {
            @strongify(self);
            self.title = LZLocalizedString(@"钱包");
        }];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
 
    [self setupUI];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //请求用户余额
    showLoadingTitle(@"", nil);
    [self.viewModel getUserAllCoin];
    [self.viewModel getWallertRecord:YES];
}

#pragma mark - setupUI
- (void)setupUI{
    [self.view addSubview:self.wallertView];
    [self.wallertView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];


}

#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (ShellWallertView *)wallertView{

    if(!_wallertView){
        _wallertView = [[ShellWallertView alloc] initViewModel:self.viewModel];
    }
    return _wallertView;
}

- (ShellWallertViewModel *)viewModel{
    if(!_viewModel){
        _viewModel = [[ShellWallertViewModel alloc] init];

    }
    return _viewModel;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
